package demo;

/**
 * @Author: Lenovo
 * @Date: 2024/6/2 16:28
 * @description:
 */
class Login{
    private String UserName;
    private String passWord;

    public String getUserName() {
        return UserName;
    }

    public void setUserName(String userName) {
        UserName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }
    public void loginInfo(String userName,String passWord)throws UseNameException,PassWordException{
            if(!this.getPassWord().equals(passWord)){
                throw  new PassWordException("密码错误");
            }
            if(!this.getUserName().equals(UserName)){
                throw new UseNameException("用户名错误");
            }
        System.out.println("登录成功");
    }

}
public class Test {
    public static void main(String[] args)throws UseNameException,PassWordException {
        Login login=new Login();
        login.setPassWord("1234");
        login.setUserName("zhangsan");
        login.loginInfo("zhangsan","1234");
    }
}
